package com.tang.controller;

import com.tang.dto.AddArticleDto;
import com.tang.dto.TagListDto;
import com.tang.sys.ResponseResult;
import com.tang.sys.entity.Article;
import com.tang.sys.service.IArticleService;
import com.tang.sys.vo.ArticleDetailVo;
import com.tang.sys.vo.PageVo;
import com.tang.sys.vo.articleListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/content/article")
public class AdminArticleController {

    @Autowired
    private IArticleService iArticleService;

    @PostMapping
    public ResponseResult add(@RequestBody AddArticleDto article){

        return iArticleService.add(article);
    }

    //获取全部文章  删除除外
    @GetMapping("/list")
    public ResponseResult<PageVo> list(Integer pageNum, Integer pageSize, AddArticleDto addArticleDto){

        return iArticleService.pageTagList(pageNum,pageSize,addArticleDto);
    }
    //删除文章
    @DeleteMapping("{id}")
    public ResponseResult<Article> deldeteArticle(@PathVariable("id") Long id){

        return iArticleService.deldeteArticle(id);

    }

    //获取id文章
    @GetMapping("{id}")
    public ResponseResult<ArticleDetailVo> getArticleInfo(@PathVariable("id") Long id){
        return iArticleService.getArticleInfo(id);
    }
    @PutMapping
    public ResponseResult updateArticleDetail(@RequestBody Article article){

        return iArticleService.updateArticleDetail(article);
    }

    //文章状态修改
    @PutMapping("/changeStatus")
    public ResponseResult updateArticleStatus(@RequestBody Article article ){

        return iArticleService.updateArticleStatus(article);
    }

    @PutMapping("/changeThumbnail")
    public ResponseResult updateArticleThumbnail(@RequestBody Article article){

        return iArticleService.updateArticleThumbnail(article);
    }
}

